home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / security / shadow-3.1.4 / motd.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-11-26  |  1.0 KB  |  50 lines

  1. /*
  2.  * Copyright 1989, 1990, 1991, John F. Haugh II
  3.  * All rights reserved.
  4.  *
  5.  * Permission is granted to copy and create derivative works for any
  6.  * non-commercial purpose, provided this copyright notice is preserved
  7.  * in all copies of source code, or included in human readable form
  8.  * and conspicuously displayed on all copies of object code or
  9.  * distribution media.
  10.  */
  11.  
  12. #include <stdio.h>
  13. #ifndef    BSD
  14. #include <string.h>
  15. #include <memory.h>
  16. #else
  17. #include <strings.h>
  18. #define    strchr    index
  19. #define    strrchr    rindex
  20. #endif
  21. #include "config.h"
  22.  
  23. #ifndef    lint
  24. static    char    _sccsid[] = "@(#)motd.c    3.1    07:43:40    9/17/91";
  25. #endif
  26.  
  27. extern    char    *getdef_str();
  28.  
  29. void    motd ()
  30. {
  31.     FILE    *fp;
  32.     char    motdlist[BUFSIZ], *motd, *mb;
  33.     register int    c;
  34.  
  35.     if ((mb = getdef_str("MOTD_FILE")) == NULL)
  36.         return;
  37.  
  38.     strncpy(motdlist, mb, sizeof(motdlist));
  39.     motdlist[sizeof(motdlist)-1] = '\0';
  40.  
  41.     for (mb = motdlist ; (motd = strtok(mb,":")) != NULL ; mb = NULL) {
  42.         if ((fp = fopen(motd,"r")) != NULL) {
  43.             while ((c = getc (fp)) != EOF)
  44.                 putchar (c);
  45.             fclose (fp);
  46.         }
  47.     }
  48.     fflush (stdout);
  49. }
  50.